// WebView页面逻辑
Page({
  data: {
    url: '',
    title: ''
  },

  onLoad(options) {
    const { url, title } = options
    this.setData({
      url: decodeURIComponent(url || ''),
      title: decodeURIComponent(title || '广告页面')
    })
  },

  onMessage(e) {
    console.log('收到webview消息:', e.detail.data)
  },

  // 分享给好友
  async onShareAppMessage() {
    const ShareUtil = require('../../utils/shareUtil')
    return await ShareUtil.generateShareAppMessageConfig('webview', {
      url: this.data.url,
      title: this.data.title
    })
  },

  // 分享到朋友圈
  async onShareTimeline() {
    const ShareUtil = require('../../utils/shareUtil')
    return await ShareUtil.generateShareTimelineConfig('webview', {
      url: this.data.url,
      title: this.data.title
    })
  }
})
